package com.yixiu.study.juc.thread;

import java.beans.IntrospectionException;

/**
 * @CalssName T04_ThreadState
 * @Description
 * @Author yixiu
 * @Date 2021/6/23 19:41
 * @Verison num1.0
 **/
public class T04_ThreadState {

    static class MyThread extends Thread{
        @Override
        public void run(){
            System.out.println(this.getState());//RUNNABLE

            for(int i=0; i<10; i++){
                try {
                    Thread.sleep(50);
                } catch (InterruptedException e){
                    e.printStackTrace();
                }
                System.out.println(i);
            }
        }
    }

    public static void main(String[] args) {
        Thread t= new MyThread();
        System.out.println(t.getState());//NEW

        t.start();

        System.out.println(t.getState());//RUNNABLE

        try {
            t.join();
        } catch (InterruptedException e){
            e.printStackTrace();
        }
        System.out.println(t.getState());//TERMINATED

    }

}
